<template>
    <div class="debris-list" v-loading="loading">
        <div class="table-box">
            <el-table :data="tableData" ref="table" border style="width: 100%">
                <el-table-column min-width="120" label="评价来源" prop="reviewUserId"></el-table-column>
                <el-table-column min-width="120" label="评价类型">
                    <template slot-scope="scope">
                        <span v-if="scope.row.type === 1">整体评价</span>
                        <span v-else>个人评分</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="120" label="分数" prop="score"></el-table-column>
                <el-table-column min-width="120" label="标签" prop="comment">
                    <template slot-scope="scope">
                        <span v-if="scope.row.comment">{{ scope.row.comment }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="120" label="默认">
                    <template slot-scope="scope">
                        <span v-if="scope.row.operatorType === 1">是</span>
                        <span v-else>否</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="120" label="组队方式">
                    <template slot-scope="scope">
                        <span v-if="scope.row.teamType === 0">创建房间</span>
                        <span v-if="scope.row.teamType === 1">快速匹配</span>
                        <span v-if="scope.row.teamType === 2">选择房间</span>
                        <span v-if="scope.row.teamType === 3">选择房间</span>
                        <span v-if="scope.row.teamType === 4">选择房间</span>
                    </template>
                </el-table-column>
                <el-table-column min-width="120" label="评价时间">
                    <template slot-scope="scope">
                        {{ tableFormatDate(scope.row.createTime) }}
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="tools">
            <el-pagination
                @size-change="sizeChange"
                @current-change="pageChange"
                :current-page="pageNum"
                :page-sizes="_pageSizes"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { formatDate } from '@/utils/utils'

export default {
    name: 'getEvaluate',
    props: {
        tabIndex: ''
    },
    data () {
        return {
            pageNum: 1,
            pageSize: this._pageSize,
            keyWord: '',
            status: null,
            date: [],
            tableData: [],
            total: 0,
            loading: false
        }
    },
    watch: {
        tabIndex (value) {
            if (value === '3') {
                this.getList(1)
            }
        }
    },
    methods: {
        // 获取列表
        async getList (startPage) {
            if (this.loading) return
            this.pageNum = startPage
            this.loading = true
            let params = {
                startPage: startPage - 1,
                pageSize: this.pageSize,
                type: 2,
                userId: this.$route.query.userId
            }
            let res = await this.$http.post('/team/getTeamPCUserRecomment', params)
            if (res.code === '0') {
                this.tableData = res.data && res.data.list
                this.total = res.data.count
            } else {
                this.$message({
                    type: 'error',
                    message: '系统异常，请稍后再试'
                })
            }
            this.loading = false
        },
        // 查看用户详情
        goUserDetail (id) {
            const { href } = this.$router.resolve({
                path: '/dataReport/userInfo',
                query: {
                    id
                }
            })
            window.open(href, '_blank')
        },
        // 页码切换
        sizeChange (val) {
            this.pageNum = 1
            this.pageSize = val
            this.getList(1)
        },
        // 页容切换
        pageChange (val) {
            this.pageNum = val
            this.getList(this.pageNum)
        },
        tableFormatDate (time) {
            return formatDate(time, 'YYYY-MM-DD HH:MM:SS')
        }
    }
}
</script>

<style lang="scss" scoped>
    .debris-list {
        .input-box {
            margin-top: 10px;
            font-size: 13px;
            font-weight: 500;
            .input-title {
                margin: 0 10px 0 20px;
            }
            .btn {
                margin-top: 10px;
                margin-left: 10px;
            }
        }

        .table-box {
            margin: 20px 0;
            .cover {
                width: 80px;
                height: 80px;
                > img {
                    width: 100%;
                    height: 100%;
                }
            }
            .user-icon {
                width: 20px;
                height: 20px;
                border-radius: 50%;
                margin-right: 5px;
                vertical-align: top;
            }
            .table-btn {
                cursor: pointer;
                color: #409EFF;
                font-size: 13px;
                font-weight: 500;
                &:hover {
                    text-decoration: underline;
                }
            }
        }
        .tools {
            padding-right: 20px;
            display: flex;
            justify-content: flex-end;
        }
    }
</style>
